/*
 * @Author: 秦福凯
 * @LastEditTime: 2024-11-20 11:56:00
 * @Description: 路由主文件
 */
import { createRouter, createWebHashHistory } from 'vue-router';
import { routes } from './router'
import 'nprogress/nprogress.css';
import NProgress from 'nprogress';
import usePermissStore from '@/store/permiss';


const router = createRouter({
	history: createWebHashHistory(),
	routes,
});

router.beforeEach((to, from, next) => {
	NProgress.start();
	// console.log(to)
	// console.log(from)
	// console.log(from.path +'=>'+ to.path)
	// const token = localStorage.getItem('token');
	// if(to.path === '/login' || to.path === '/') return  next();
	// //console.log( to,token,permiss.admin,'tooooooooo')
	// //console.log(!token , !to.meta.noAuth,'ttttttttttt')
	// if(!token) return next('/login');
	// //有token，页面不需要权限时直接跳转
	// if (to.meta?.noAuth) return next();
	// console.log(usePermissStore().permiss,'permiss')
	// //没有页面权限则跳到403
	// if (typeof to.meta.permiss == 'string' && !usePermissStore().permissList.includes(to.meta.permiss)) {
	//     console.log(2222)
	//     // 如果没有权限，则进入403
	//     next('/403');
	//     return
	// }
	//sessionStorage中没有菜单以及菜单列表则回到 选择子系统页
	next();
});

router.afterEach(() => {
	NProgress.done();
});

export default router;
